import java.util.Enumeration;
import java.util.Iterator;
import java.util.Vector;

public class VectorTest {
    public static void main(String[] args) {
        Vector vector = new Vector();
        vector.addElement("abc1");
        vector.addElement("abc2");
        vector.addElement("abc3");
        vector.addElement("abc4");

        Enumeration enumeration = vector.elements();
        System.out.println(enumeration);

        //Enumeration遍历元素
        while(enumeration.hasMoreElements()){
            System.out.println(enumeration.nextElement());
        }

        //Iterator遍历元素
        Iterator it = vector.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }

        //获取元素
        System.out.println(vector.get(1));
    }
}
